package org.oep.game;

import java.io.IOException;
import java.util.Hashtable;

import javax.microedition.lcdui.Image;

public class ImageStore {
	private static ImageStore singlet = new ImageStore();
	private Hashtable images = new Hashtable();
	
	public static ImageStore getInstance() {
		return singlet;
	}
	
	private void load(String ref) throws IOException {
		Image source;
		source = Image.createImage(ref);
		images.put(ref, source);
	}
	
	public Image get(String ref) throws IOException {
		if(images.get(ref) != null) {
			return (Image) images.get(ref);
		}

		load(ref);
		return (Image) images.get(ref);
	}

}
